/*
 * COPYRIGHT:	2010 Christopher Smith, licenced under the GNU GPL v2; see COPYING in the top level directory
 * PROJECT:		sdedit
 * FILE:		objtypes.cpp
 * PURPOSE:		base class of all securable object types
 */

namespace ObjectTypes
{

namespace Specific
{

PCWSTR NullLabels[DESC_SPECIFIC_SIZE];

}//namespace Specific

struct Object;

struct ChildrenWalkDest
{
	virtual void Proc(Object &Co) = 0;
};

struct Object : auto_refctd_std_base
{
	PCWSTR const *SpecificHeaders;
	auto_szpod<WCHAR> Name;
	auto_array<auto_szpod<WCHAR> > PathComponents;

	Object(PCWSTR const *SpecificHeaders = NULL, PCWSTR Name = NULL) :
		SpecificHeaders(SpecificHeaders ? SpecificHeaders : Specific::NullLabels),
		Name(Name)
	{}

	Object(PCWSTR const *SpecificHeaders, auto_take<WCHAR> Name) :
		SpecificHeaders(SpecificHeaders ? SpecificHeaders : Specific::NullLabels),
		Name(Name)
	{}

	//query maximum information for single object
	virtual void QueryEditState(OUT SD_EDIT_STATE &Es) = 0; 
	
	//query specified information for single object
	virtual void QueryEditState(IN SECURITY_INFORMATION Si, OUT SD_EDIT_STATE &Es) = 0;

	//set edit state of single object
	virtual void SetEditState(IN SD_EDIT_STATE const &Es) = 0;
	
	//walk nothing if no children
	virtual void WalkChildren(IN ChildrenWalkDest &Dest, UCHAR Privileges)
	{}

	//return null if no parent available, raise if a parent exists but couldn't be opened
	virtual Object *OpenParent(UCHAR Privileges)
	{
		return NULL;
	}

	//query information with any hierarchical state
	virtual void QueryTreeEditState(OUT SD_EDIT_STATE &Es, UCHAR Privileges)
	{
		QueryEditState(Es);
	}

	//set information for hierarchy
	virtual void SetTreeEditState(IN SD_EDIT_STATE const &Es, UCHAR Privileges)
	{
		SetEditState(Es);
	}

	virtual GENERIC_MAPPING GetGenericMapping()
	{
		GENERIC_MAPPING EmptyGm;
		RtlZeroStruct(EmptyGm);
		return EmptyGm;
	}

	virtual ~Object() {}
};

}//namespace ObjectTypes